package com.gtq.uhome.controller;

import com.gtq.uhome.result.Result;
import com.gtq.uhome.service.DistributionPersonalCenterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 配送员个人中心
 */
@RestController
@RequestMapping(value = "/courierInfo")
@CrossOrigin
@Api(tags = "配送端口 配送员个人中心接口说明文档 咨询李龙")
public class DistributionPersonalCenterController {
    @Resource
    DistributionPersonalCenterService distributionPersonalCenterService;
    /**
     * 派送员相关信息
     * @return 返回派送员消息
     */
    @PostMapping
    @ApiOperation(value = "展示派送员信息", notes = "展示派送员信息", response = Map.class, httpMethod = "POST")
    public Result courierInfo(@RequestBody Map<String,Integer> map){
        //获取前端传值
        Integer courierId = map.get("courierId");
        //打印获取值
        System.out.println("获取到派送员ID："+courierId);
        //调用方法
        Map<String,Object> courierInfo = distributionPersonalCenterService.CourierInfo(courierId);
        if (courierInfo!=null){
            return Result.ok(courierInfo,"查询成功");
        }
        return Result.failed("查询失败，请联系客服");
    }

    /**
     * 派送员的消息中心
     * @return 返回派送员消息
     */
    @PostMapping("/courierMsg")
    @ApiOperation(value = "派送员消息中心", notes = "派送员的个人消息中心", response = Map.class, httpMethod = "POST")
    public Result selectCourierMsg(@RequestBody Map<String,Integer> map){
        //获取前端传值
        Integer courierId = map.get("courierId");
        //打印获取值
        System.out.println("获取到派送员ID："+courierId);
        //调用方法
        List<String> strings = distributionPersonalCenterService.CourierMsg(courierId);
        if (strings!=null){
            return Result.ok(strings,"查询成功");
        }
        return Result.failed("暂无消息通知");
    }



}
